<template>
  <div class="Foot">
    <div class="nav">
      <span
        @click="handleClick(index)"
        v-for="(item, index) in tablist"
        :key="index"
        :class="{
          iconfont: true,
          [item.icon]: true,
          active: currentIndex == index,
        }"
        >{{ item.text }}</span
      >
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      currentIndex: 0, //用来保存点击的下标
      tablist: [
        { icon: "icon-home", text: "首页" },
        { icon: "icon-order", text: "订单" },
        { icon: "icon-mine", text: "我的" },
      ],
    };
  },
  methods: {
    handleClick(index) {
      //保存点击的下标
      this.currentIndex = index;
    },
  },
};
</script>

<style scoped>
.nav {
  width: 100%;
  height: 60px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  box-sizing: border-box;
  background-color: rgba(0, 0, 0, 0.709);
  position: absolute;
  bottom: 0px;
  background-color: #ccc;

}
.nav span.active {
  color: red;
  font-weight: bold;
}
</style>